stage.set_background("schoolhallway")
sprite = codesters.Sprite("person8")
stage.set_gravity(4)
stage.disable_floor()
sprite.set_gravity_off()
sprite.go_to(0, -220)
score = 0
score_board = codesters.Display(score)
my_info = ["cellphone", "address", "birthdate"]
def left_key():
sprite.move_left(20)
# add other actions...
stage.event_key("left", left_key)
def right_key():
sprite.move_right(20)
# add other actions...
stage.event_key("right", right_key)
def interval():
x = random.randint(-230, 230)
info_img = random.choice(my_info)
# add any other actions...
stage.event_interval(interval, 3)
t = codesters.Teacher()
try:
sp_params = t.get_parameters_for_function('Sprite')
sp_line = t.find_function('Sprite')
tval1 = sp_line[1][1].replace(' ', '')
tval2 = t.get_indent_at_line(sp_line[1][0])
except:
tval1 = "DNE"
tval2 = "DNE"
try:
sp_params = t.get_parameters_for_function('Sprite')
sp_line = t.find_function('Sprite')
tval3 = sp_params[1][0]
tval4 = sp_params[1][1]
tval5 = sp_params[1][2]
except:
tval3 = "DNE"
tval4 = "DNE"
tval5 = "DNE"
#print tval1
t1 = TestObjective()
t1.add_success('info=' in tval1 and tval2 == 4 and 'info_img' in tval1, "Great job!")
t1.add_failure(tval1 == "DNE", "Did you add a Sprite at Position to your Interval Event?")
t1.add_failure('info=' not in tval1, "Did you change the name of your sprite to info?")
t1.add_failure('"codester"' in tval1, "Did you change the image to info_img?")
t1.add_failure('info_img' not in tval1, "Did you change the image to info_img?")
t1.add_failure(tval2 < 4, "Did you indent your Sprite in your Interval Event?")
t1.add_failure(tval2 > 4, "Oops! Make sure you only indent your sprite 4 spaces inside the Interval Event!")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)